<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ include file="../common/taglibs.jsp"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>POS收单运营管理平台</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<title>商户批量导入</title>
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<!-- 当前页面样式 -->
<link rel="stylesheet" href="<s:url value="/css/common.css"/>" />
<!-- 当前页面样式 END -->
<script type="text/javascript"
	src="<c:url value="/js/jquery-1.3.2.js" />"></script>
<script type="text/javascript" src="<c:url value="/js/common.js" />"></script>
<script language="javascript" type="text/javascript"
	src="<c:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
<script type='text/javascript' src='<s:url value="/dwr/engine.js"/>'></script>
<script type='text/javascript'
	src='<s:url value="/dwr/interface/MccQuery.js"/>'></script>

<script type="text/javascript">
	
	function importSubmit(){
		var imporNum = $.trim($("#imporNum").val());
		if(!imporNum){
			alert("请输入导入的商户总数");
			return false;
		}
		
		if(!/^\d+$/.test(imporNum)){
			alert("请输入整数");
			return false;
		}
		
		if(parseInt(imporNum)>500){
			alert("一次最多导入500条记录");
			return false;
		}
		 
		
		var upload = $.trim($("#upload").val());
		if(!upload){
			alert("请选择要上传的文件");
			return false;
		}
		var suffix = upload.substring(upload.lastIndexOf(".")+1);
		if("xlsx" != suffix){
			alert("请上传后缀名为xlsx的文件");
			return false;
		}
		
		$("#merinfoBatchImportForm").attr("action","<%=basePath%>/mer/merInfoBatchImport.ct");
		$("#merinfoBatchImportForm").submit();
		$("#importMerinfo").attr("disabled",true);
		$("#upload").attr("disabled",true);
		
	}
	
	
	function exportModel(){
		$("#merinfoBatchImportForm").attr("action","<%=basePath%>/mer/downloadModel.ct");
		$("#merinfoBatchImportForm").submit();
	}
	
	function importGoOn(){
		window.location.href="<%=basePath%>/mer/merInfoBatchImportInit.ct";
	}
</script>



</head>

<body>

	<s:form id="merinfoBatchImportForm" action="" method="post"
		theme="simple" enctype="multipart/form-data">
		<table class="tb">
			<tbody>
				<tr class="tb-line">
					<td class="tb-td" colspan="4"><div class="tb-h2">POS收单运营管理平台</div></td>
				</tr>

				<tr class="tb-line">
					<td class="tb-td" colspan="4"><div class="tb-h3">商户批量导入</div></td>
				</tr>

				<tr class="tb-line">
					<td width="12%" style="min-width: 150px" align="right"
						class="tb-td">
						<div class="tb-h4">导入商户数量：</div>
					</td>
					<td class="tb-td"><label class="tb-input-normal"><s:textfield
								id="imporNum" name="imporNum" cssClass="queryWidth" /></label>
					</td>
					<td width="12%" style="min-width: 150px" align="right"
						class="tb-td"><div class="tb-h4">商户批量导入：</div></td>
					<td class="tb-td" style="width: 400px;"><label><s:file
								id="upload" name="upload" class="tb-input-mini"></s:file></label><label><input
							type="button" onclick="importSubmit();" value="导入"
							class="tb-input-mini" id="importMerinfo" /></label> <label><input
							onclick="importGoOn()" type="button" value="继续导入"
							class="tb-input-mini" /></label></td>
					
				</tr>
				<tr class="tb-line">
					<td width="12%" style="min-width: 150px" align="right"
						class="tb-td">
						<div class="tb-h4">商户批导模板下载：</div>
					</td>
					<td class="tb-td"><input type="button"
						onclick="exportModel();" value="商户批导模板下载" /></td>
				</tr>


				<tr>
					<td colspan="8" align="center"><span style="font-color: red"><s:actionerror /></span>
						<span style="font-color: red;"> <s:actionmessage /></span> <span
						style="font-color: red;"><s:fielderror
								cssClass="fieldError" /></span> <span id="otherError"
						style="font-color: red"></span></td>
				</tr>

				<tr>
					<td colspan="8">&nbsp;<s:token></s:token></td>
				</tr>
			</tbody>
		</table>

	</s:form>
</body>
</html>